import request from '@/utils/request'
import wyrequest from '@/utils/wyrequest'
export const reqPagesData = (page,size)=>{
    return wyrequest({
        url:`/topic/v1/find/recAuto.json?page=${page}&size=${size}`,
        method:'get',
    })
}
export const reqNavWapList = ()=>{
    return wyrequest({
        url:"/topic/v1/know/navWap.json",
        method:'get',
    })

}
//登录请求
export const reqUserLogin = (userInfo) => {
    return request({
      url:'/user/passport/login',
      method:'post',
      data:userInfo
    })
}

//请求获取用户信息
export const reqUserInfo = () => {
    return request({
      url:'/user/passport/auth/getUserInfo',
      method:'get'
    })
}

//退出登录请求
export const reqUserLogout = () => {
    return request({
      url:'/user/passport/logout',
      method:'get'
    })
}

// 请求默认关键字和热门关键字
export const reqKeywordList = () => {
  return wyrequest({
    url:'/xhr/search/init.json',
    method:'get'
  })
}

//请求实时关键字列表
export const reqRealtimeKeywordList = (searchKeyword) => {
  return wyrequest({
    url:'/xhr/search/searchAutoComplete.json',
    method:'post',
    headers: {
      "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    data: "keywordPrefix=" + searchKeyword
  })
}

//搜索请求
export const reqSearch = (searchKeyword) => {
  return wyrequest({
    // url:'xhr/search/search.json?keyword=' + searchKeyword,
    url:'xhr/search/search.json?__timestamp=1630133434953&needPopWindow=true&searchWordSource=7&stillSearch=false&_stat_search=autoComplete&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=' + searchKeyword,
    method:'get',
  })
}

// 请求获取购物车列表数据
export const reqShopCartList = () => {
  return request({
    url: '/cart/cartList',
    method: 'get'
  })
}

// 请求添加购物车
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
  return request({
    url: `/cart/addToCart/${ skuId }/${ skuNum }`,
    method: 'post'
  })
}


// 请求修改单个购物车商品的选中状态
export const reqUpdateOneCartIsCheck = (skuId, isChecked) => {
  return request({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'get'
  })
}

// 请求修改多个购物车商品的选中状态
export const reqUpdateAllCartIsCheck = (skuIdList, isChecked) => {
    return request({
      url: `/cart/batchCheckCart/${isChecked}`,
      method: 'post',
      data: skuIdList
    })
}

//删除多个商品
export const reqDeleteAllCart = (skuIdList) => {
  return request({
    url: '/cart/batchDeleteCart',
    method: 'delete',
    data: skuIdList
  })
}


// 请求获取详情页数据
export const reqGoodsDetailInfo = (skuId) => {
  return request({
    url: `/item/${ skuId }`,
    method: 'get',
  })
}


